package cn.cn.tedu.file;

import java.io.*;

/**
 * @author ：Dsi
 * @date ：2021/11/16 15:44
 * Describe ：
 */
public class TestOut2 {
    public static void main(String[] args) {
        //method1();//普通输出流（将java程序中缓存的输出至硬盘中）
        method2();
    }

    private static void method2() {
        BufferedWriter bw1=null;
        BufferedWriter bw2=null;
        try {
            bw1=new BufferedWriter(new FileWriter("D:\\ready\\2.txt"));
            bw1.write("123",1,2);
            bw2=new BufferedWriter(new FileWriter("D:\\ready\\2.txt",true));
            bw2.write("5465468798754687987968",1,20);
        }catch (Exception e){
            e.printStackTrace();
        }finally {
            try{
                bw1.close();
            }catch(Exception e){
                e.printStackTrace();
            }
        }




    }

    private static void method1() {
        FileWriter w=null;
        try {
            w=new FileWriter("D:\\ready\\2.txt",true);
            w.write(97);
        } catch (Exception e) {
            e.printStackTrace();
        }finally {
            try{
                w.close();
            }catch (Exception e){
                e.printStackTrace();
            }
        }


    }
}
